function ParseSiteCtrl($rootScope, $scope, $http) {

	$scope.parsePageRq = {};
	$scope.result = {};
	$scope.stores = [];

	$scope.showHide = function(item) {
		$('#' + item).slideToggle();
	};

	$scope.getTemplate = function() {
		$http.post(DOMAIN + '/admintool/page/pagerq').success(function(data) {
			$scope.parsePageRq = data;
		});
	};

	$scope.parse = function() {
		$("#loader").fadeIn('fast');
		document.getElementById("btnParse").disabled=true;
		$http.post(DOMAIN + '/admintool/site/parse', $scope.parsePageRq)
				.success(function(data) {
					if (data == undefined || data == null) {
						alert('Parsing Error!');
					}
					$scope.result = data;
					$("#loader").fadeOut('fast');
					document.getElementById("btnParse").disabled = false;
					$scope.initCat();
				});
	};

	$scope.getStores = function() {
		$http.post(DOMAIN + '/data/store/getall').success(function(data) {
			$scope.stores = data;
			$scope.parsePageRq.storeId = $scope.stores[0].id;
		});
	};
	$scope.initCat = function() {
		for ( var int = 0; int < $scope.categories.length; int++) {
			for ( var int2 = 0; int2 < $scope.categories[int].children.length; int2++) {
				$scope.cat.push($scope.categories[int].children[int2]);
			}
		}
	};

	// -------- Init ------
	$scope.getTemplate();
	$scope.getStores();
}
SiteCtrl.$inject = [ '$rootScope', '$scope', '$http' ];